<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>idamax.f</title>
 <meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.comment   { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.comment a { color: rgb(178, 34, 34);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
      INTEGER FUNCTION <a name="IDAMAX.1"></a><a href="idamax.f.html#IDAMAX.1">IDAMAX</a>(N,DX,INCX)
<span class="comment">*</span><span class="comment">     .. Scalar Arguments ..
</span>      INTEGER INCX,N
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Array Arguments ..
</span>      DOUBLE PRECISION DX(*)
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">  Purpose
</span><span class="comment">*</span><span class="comment">  =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     finds the index of element having max. absolute value.
</span><span class="comment">*</span><span class="comment">     jack dongarra, linpack, 3/11/78.
</span><span class="comment">*</span><span class="comment">     modified 3/93 to return if incx .le. 0.
</span><span class="comment">*</span><span class="comment">     modified 12/3/93, array(1) declarations changed to array(*)
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     .. Local Scalars ..
</span>      DOUBLE PRECISION DMAX
      INTEGER I,IX
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC DABS
<span class="comment">*</span><span class="comment">     ..
</span>      <a name="IDAMAX.25"></a><a href="idamax.f.html#IDAMAX.1">IDAMAX</a> = 0
      IF (N.LT.1 .OR. INCX.LE.0) RETURN
      <a name="IDAMAX.27"></a><a href="idamax.f.html#IDAMAX.1">IDAMAX</a> = 1
      IF (N.EQ.1) RETURN
      IF (INCX.EQ.1) GO TO 20
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        code for increment not equal to 1
</span><span class="comment">*</span><span class="comment">
</span>      IX = 1
      DMAX = DABS(DX(1))
      IX = IX + INCX
      DO 10 I = 2,N
          IF (DABS(DX(IX)).LE.DMAX) GO TO 5
          <a name="IDAMAX.38"></a><a href="idamax.f.html#IDAMAX.1">IDAMAX</a> = I
          DMAX = DABS(DX(IX))
    5     IX = IX + INCX
   10 CONTINUE
      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">        code for increment equal to 1
</span><span class="comment">*</span><span class="comment">
</span>   20 DMAX = DABS(DX(1))
      DO 30 I = 2,N
          IF (DABS(DX(I)).LE.DMAX) GO TO 30
          <a name="IDAMAX.49"></a><a href="idamax.f.html#IDAMAX.1">IDAMAX</a> = I
          DMAX = DABS(DX(I))
   30 CONTINUE
      RETURN
      END

</pre>

 </body>
</html>
